package com.kklsqm.langchain4j.controller;

import com.kklsqm.langchain4j.dto.VoiceRequestDTO;
import com.kklsqm.langchain4j.service.impl.LangChainTTSServiceImpl;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 功能: 语音合成控制器
 * 作者: 沙琪马
 * 日期: 2025/4/23 11:13
 */
@RestController
@RequestMapping("/api/tts")
public class TTSController {

    private final LangChainTTSServiceImpl ttsService;

    public TTSController(LangChainTTSServiceImpl ttsService) {
        this.ttsService = ttsService;
    }

//    @PostMapping(produces = "audio/mpeg")
//    public ResponseEntity<byte[]> tts(@RequestBody VoiceRequestDTO request) {
//        // 手动校验请求参数
//        request.validate();
//
//        byte[] audio = ttsService.generateSpeech(request);
//        return ResponseEntity.ok()
//                .header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"speech.mp3\"")
//                .contentType(MediaType.parseMediaType("audio/mpeg"))
//                .body(audio);
//    }
}

